//--------------------------------------------------------------------------------------
// create the registry table. Each element wil be a couple (func_name_in_py, func_name_in_js).
// each include which is supposed to retrive a json json_name_from_py from a function func_name_in_py and apply func_name_in_js to it must start with

// var newRegistery = new Array(func_name_in_py, func_name_in_js );
// allJsonsRegistry.concat(newRegistery)

// Variable into which included files register the name of the function in python and the name of the function in js to apply to the
// result of the call to the pyton function  
// do not set "var" to have a global variable
allJsonsRegistry = new Array();

//--------------------------------------------------------------------------------------
// return the number of registered func, aka, the number of include which are registering themselves
function getNumberOfRegisteredCalls()
{
    return allJsonsRegistry.length / 2;
};


//--------------------------------------------------------------------------------------
//return the name of the ith js function
function getGetJSFuncName( i ) 
{   
   return allJsonsRegistry.slice( 2 * i + 1, 2*i + 2 );
};

//--------------------------------------------------------------------------------------
//return the name of the ith py function
function getGetPyFuncName( i ) 
{   
   return allJsonsRegistry.slice( 2 * i , 2*i + 1 );
};

//--------------------------------------------------------------------------------------
//return the js function which name is 'name'
function getGetJSFuncByName( name ) 
{   
    var func = window[name];
    if( typeof(func) == 'undefined' )
    {
        debugger;
        alert( 'function ' + name + ' not in function dictionary' );
    }
    return func;
};

//--------------------------------------------------------------------------------------
//return the list of the call to python code as a string representing a dictionary
function makeCallsListAsString() 
{   
    var lenght = getNumberOfRegisteredCalls();
    var tmp = '{\'callsList\':[';
    for (var i = 0; i < lenght - 1; i++) 
    {
	    tmp= tmp + '{\'pyFuncName\':\''+getGetPyFuncName(i)+'\',\'jsFuncName\':\'' +getGetJSFuncName(i) + '\'},';
    }
    var pyFuncName = getGetPyFuncName(lenght - 1);
    tmp= tmp + '{\'pyFuncName\':\''+getGetPyFuncName(i)+'\',\'jsFuncName\':\'' + getGetJSFuncName(i)+ '\'}';
    tmp = tmp + ']}';
    return tmp;
 };
 
//--------------------------------------------------------------------------------------
//import the pakage needed for the display
google.load('visualization', '1', {'packages':['table']});
google.load("visualization", '1', {'packages':['corechart']});
google.load('visualization', '1', {'packages': ['piechart']});
